import { defineStore } from 'pinia';
import { IActive } from '@/types/data';
import { useRouter } from 'vue-router';

const footerStore = defineStore('footer', {
	state: () => {
		return {
			tabs: ['所有', '未完成', '已完成'] as IActive[],
			active: '所有' as IActive,
			activeHash: ['all', 'active', 'compelete'],
		}
	},
	actions: {
		getActive() {
			const router = useRouter();
			const path = router.currentRoute.value.path.split('/');
			const hs = path[path.length - 1];
			const idx = this.activeHash.indexOf(hs);
			this.active = this.tabs[idx];
		},

	}
})

export default footerStore